{% extends "base.html" %}
{% comment %}
Copyright 2010 Google Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
{% endcomment %}

{% load i18n %}
{% block content %}
{% include "query_form.html" %}
{% if results %}
  {% ifequal params.role 'seek' %}
    <h1>{% trans "Search Results for" %}:
      {{params.query}}</h1>
  {% endifequal %}

  {% ifequal params.role 'provide' %}
    <h1>{% trans "Records Similar to" %}: {{env.params_full_name}}</h1>
    <p>
    {% if not params.small %}
      {% ifequal num_results 1 %}
        {% trans "There is one existing record with a similar name." %}
      {% else %}
        {% trans "There are some existing records with similar names." %}
      {% endifequal %}
      {% trans "Please check whether it matches the person you were planning to report." %}
    {% endif %}
  {% endifequal %}

  {% if params.small %}
    {% ifequal num_results 1 %}
      {% trans "There is one existing record with a similar name." %}
    {% else %}
      {% blocktrans %}There are {{num_results}} existing records with similar names.{% endblocktrans %}
    {% endifequal %}
    <p>
    <a class="results-found" href="{{results_url}}" target="_blank">
      {% trans "Click here to view results." %}
    </a>
  {% else %}
    <p>
    {% trans "To view or add information, select a name below." %}
    <a href="#" id="dup_on_link" style="display:none" onclick="return set_dup_mode(true);">{% trans "Switch to duplicate marking mode" %}</a>
    <a href="#" id="dup_off_link" style="display:none" onclick="return set_dup_mode(false);">{% trans "Switch to normal view mode" %}</a><br />
    {% trans "Note: Alternate names may be machine generated and may not be accurate." %}
    <ul class='searchResults'>
    {% for result in results %}
      {% ifchanged result.is_address_match %}
        {% if result.is_address_match %}
          <hr style="margin-top:30px;">
          <h1>{% blocktrans with params.query as query %}Records with names and addresses matching "{{query}}"{% endblocktrans %}</h1>
        {% endif %}
      {% endifchanged %}
      <li class="resultItem">
        <a class="result-link" href="{{result.view_url}}">
          <!-- no whitespace inside .resultImageContainer-->
          {% if result.photo_url %}
          <span class="resultImageContainer"
            ><img class='resultImage' src='{{result.photo_url}}'
          /></span>
          {% else %}
          <span class="resultImageContainer"
            ><img class="resultImage" src="/static/no-photo.gif"
          /></span>
          {% endif %}
          <span class='resultData'>
            <input style='display:none; float:{{env.rtl|yesno:"right,left"}}' type='checkbox' name='dup' value='{{result.record_id}}' onclick='check_dup(this);' class='duplicate-checkbox'>
            <span class='resultDataTitle'>
              {{result.full_name}}
              {% if result.alternate_full_name %}
                ({{result.alternate_full_name}})
              {% endif %}
            </span>
            <ul>
              {% if result.home_street or result.home_neighborhood or result.home_city or result.home_state or result.home_postal_code %}
              <li>{% trans "Home address" %}:
                  {% if result.home_street %}
                    {{result.home_street}}&nbsp;&nbsp;
                  {% endif %}
                  {% if result.home_neighborhood %}
                    {{result.home_neighborhood}}&nbsp;&nbsp;
                  {% endif %}
                  {% if result.home_city %}
                    {{result.home_city}}&nbsp;&nbsp;
                  {% endif %}
                  {% if result.home_state %}
                    {{result.home_state}}&nbsp;&nbsp;
                  {% endif %}
                  {% if result.home_postal_code %}
                    {{result.home_postal_code}}&nbsp;&nbsp;
                  {% endif %}
              </li>
              {% endif %}
              <li>{% trans "Status" %}:
                <span class='resultDataPersonFound'>
                  {{ result.latest_note_status }}
                </span>
              </li>
              {% if result.provider_name %}
	      <li>
                {% trans "Provided by:" %} {{result.provider_name}}
              </li>
              {% endif %}
            </ul>
            <span class="tracking">
              ID: {{result.record_id}}
            </span>
          </span>
        </a>
      </li>
    {% endfor %}
    </ul>
    <div id='dup_form' style='display:none'>
      {% trans "Select up to 3 records to mark as duplicate:" %}
      <input type="hidden" id="dup_state" value="">
      <form action="/multiview" method="get" onsubmit="mark_dup()">
        {{env.subdomain_field_html|safe}}
        <input type='hidden' name='id1' id='id1' value=''>
        <input type='hidden' name='id2' id='id2' value=''>
        <input type='hidden' name='id3' id='id3' value=''>
        <input id='dup_go' disabled='disabled' type='submit' value='{% trans "Mark records as duplicate" %}'>
        <span id='dup_count'></span> {% trans "Records selected" %}
      </form>
    </div>
    <script type='text/javascript'>
      init_dup_state();
    </script>
  {% endif %}

  <p>
  {% if not params.small %}
    {% trans "If none of these records match the person you had in mind, you can click below to create a new record." %}
  {% endif %}
{% else %}

  {% if not jp_phone_number_query %}
  <h1>{% trans "No results found for" %}:
    {{params.query}}</h1>
  <p>
  {% trans "We have nothing matching your search." %}
  {% else %}
  <h1>{{params.query}}: {% blocktrans %}No messages are found registered to the carrier's message board service.{% endblocktrans %}</h1>
  {% endif %}
  {% if params.small and not jp_phone_number_query %}
    <p>
    <a class="create-new-record" href="{{create_url}}" target="_blank">
      {% trans "Follow this link to create a new record" %}
    </a>
  {% endif %}

{% endif %}

<p>
{% if not params.small and not jp_phone_number_query %}
  <form method="get" action="/create">
    {{env.subdomain_field_html|safe}}
    <input type="hidden" name="query" value="{{params.query}}">
    <input type="hidden" name="first_name" value="{{params.first_name}}">
    <input type="hidden" name="last_name" value="{{params.last_name}}">
    <input type="hidden" name="role" value="{{params.role}}">
    {% ifequal params.role 'provide' %}
      <input type="submit" value="{% trans "Create a new record for" %} {{env.params_full_name}}">
    {% else %}
      <input type="submit" value="{% trans "Create a new record for a missing person" %}">
    {% endifequal %}
  </form>
{% endif %}

<p>
<div class="custom-message">
  {{env.results_page_custom_html|default:""|safe}}
</div>

{% endblock %}
